pub mod common;

type Real = f64;

pub struct CsrMatrix {
    pub col_index: Vec<usize>,
    pub row_ptr: Vec<usize>,
    pub value: Vec<Real>,
    pub num_rows: usize,
    pub num_cols: usize,
    pub nnz: usize,
}

pub struct CooMatrix {
    pub row_index: Vec<usize>,
    pub col_index: Vec<usize>,
    pub value: Vec<Real>,
    pub num_rows: usize,
    pub num_cols: usize,
    pub nnz: usize,
}

pub struct Spmv {
    pub coo_A: CooMatrix,
    pub A: CsrMatrix,
    pub d_A: CsrMatrix,
    pub x: Vec<Vec<Real>>,
    pub y: Vec<Vec<Real>>,
    pub numberxy: i32,
}

impl CsrMatrix {
    // 关联函数，类似于构造函数
    pub fn new() -> CsrMatrix {
        CsrMatrix {
            col_index: Vec::new(),
            row_ptr: Vec::new(),
            value: Vec::new(),
            num_rows: 0,
            num_cols: 0,
            nnz: 0,
        }
    }
}

impl CooMatrix {
    // 关联函数，类似于构造函数
    pub fn new() -> CooMatrix {
        CooMatrix {
            col_index: Vec::new(),
            row_index: Vec::new(),
            value: Vec::new(),
            num_rows: 0,
            num_cols: 0,
            nnz: 0,
        }
    }
}

impl Spmv {
    pub fn new() -> Spmv {
        Spmv {
            coo_A: CooMatrix::new(),
            A: CsrMatrix::new(),
            d_A: CsrMatrix::new(),
            x: Vec::new(),
            y: Vec::new(),
            numberxy: 10,
        }
    }
}
